package pers.karl.design.decorator;

/**
 * 计时器 装饰器，用于统计耗时
 */
public class TimerDecorator implements DoService {

    private DoService doService;

    public TimerDecorator(DoService doService) {
        this.doService = doService;
    }

    @Override
    public void doSomething() {
        long start = System.currentTimeMillis();
        doService.doSomething();
        long during = System.currentTimeMillis() - start;
        System.out.println("耗时：" + during + "毫秒");
    }

}

